import { Schema } from 'mongoose';
import { chatRoomStatus } from '@/enums/chatEnums';

// 聊天室
export const ChatRoomSchema = new Schema({
  // 聊天室人员
  creator: {
    type: Schema.Types.ObjectId,
    required: true,
    ref: 'users'
  },
  users: [{
    required: true,
    type: Schema.Types.ObjectId,
    ref: 'users'
  }],
  // 聊天室状态
  status: {
    type: String,
    required: true,
    enum: Object.values(chatRoomStatus),
    default: chatRoomStatus.enable
  },
  // 聊天室介绍
  description: {
    type: String,
    required: false
  },
}, {
  timestamps: true
});